<?php
/**
 * Created by PhpStorm OF yuyi.
 * User: YUYI
 * Date: 2018/5/8 0008
 * Time: 下午 5:26
 * Administrator
 */

namespace app\admin\controller;


use app\common\controller\Base;
use app\common\model\Articles;
use app\common\model\Menus;
use app\common\util\PostUtil;

class Index extends Base
{
    use PostUtil;
    protected $isPublic = ['index'];

    public function index()
    {
        return $this->fetch();
    }

    /**
     * 首页（引导页）
     * @return mixed
     */
    public function home(){
        $menusModel = new Menus();
        $menus = $menusModel->where(['pid'=>0,'type'=>1,'flag'=>99])->order('id asc')->select();
        foreach ($menus as $key => $menu){
            $menus[$key]['son'] = $menusModel->where(['pid'=>$menu['id'],'flag'=>99])->order('id asc')->select();
        }
        $this->assign('menus',$menus);
        $articles = Articles::all(['status'=>10]);
        $this->assign('toBeAuditedArticles',$articles);
        return $this->fetch();
    }
}